import axios from "axios"

class MyUploadAdapter{
    constructor(loader) {
        this.loader = loader;
    }

    async upload(){
        const data = new FormData();
        data.append("picData", await this.loader.file);

        const res = await axios({
            url: "http://localhost:8080/company/headline/1/image",
            method: "POST",
            data,
            withCredentials: true,
        });

        // 需要的数据可以在这里拿到
        console.log(res.data);

        return {
            //插入到Editor里的内容 E.G.:<p><img src="http://localhost:8080/company/headline/1/image/dyp">Content of the editor.</p>
            default:"http://localhost:8080/company/headline/1/image/dyp"
        };
    }
}

export default MyUploadAdapter;